package com.xd.core.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.xd.core.api.dto.SinglePayDto;
import com.xd.core.bill.dto.BillQuery;
import com.xd.core.bill.dto.ReceivePaymentQuery;
import com.xd.core.bill.vo.BillDetailVo;
import com.xd.core.bill.vo.BillPageVo;
import com.xd.core.bill.vo.EarlyRepaymentDetailVo;
import com.xd.core.bill.vo.ReceivePaymentPageVo;
import com.xd.core.bill.vo.*;
import com.xd.core.business.dto.RepaymentScheduleAppDto;
import com.xd.core.business.dto.RepaymentScheduleDto;
import com.xd.core.business.entity.RepaymentSchedule;
import com.xd.core.business.vo.BillInfoVo;
import com.xd.core.business.vo.RepayDetailVo;
import com.xd.core.business.vo.RepaymentScheduleList;
import com.xd.core.company.dto.HomeQueryDto;
import com.xd.core.company.vo.DelayCounts;
import com.xd.core.debt.dto.DebtOneDto;
import com.xd.core.finance.dto.KeepBookingDto;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 还款计划表 Mapper 接口
 * </p>
 *
 * @author ZX
 * @since 2025-02-28
 */
public interface RepaymentScheduleMapper extends BaseMapper<RepaymentSchedule> {

    void insertSchedule(@Param("schedules") List<RepaymentSchedule> schedules);

    Page<BillPageVo> selectBillList(@Param("billQuery") BillQuery billQuery, @Param("companyId") Integer companyId, @Param("userIds") List<Integer> userIds);

    Page<ReceivePaymentPageVo> selectReceivePaymentList(@Param("billQuery") ReceivePaymentQuery query, @Param("companyId") Integer companyId, @Param("userIds") List<Integer> userIds);

    Integer selectCompanyId(String transId);

    void updateStatus(Integer id, BigDecimal repayAmount);

    void updateFailCause(Integer id);

    void updateStatus1(List<Integer> incomingIds);

    void updateStatusAndOverdue(List<RepaymentSchedule> repaymentSchedules);

    void updateRepaymentType(Integer id, String status);

    void updateRepayTimes(Integer id);

    void clearRepayTimes();

    Integer getOutId(Integer orderId);

    SinglePayDto selectSinglePay(Integer outId);

    BigDecimal getTotalInterest(@Param("incomingId") Integer incomingId, @Param("outId") Integer outId);

    DelayCounts getDelayCounts(HomeQueryDto query, Integer companyId);

    String getFirstOverdueDate(@Param("incomingId") Integer incomingId, @Param("outId") Integer outId);

    Page<BillInfoVo> getList(@Param("dto") RepaymentScheduleDto dto);

    void updateAmount(KeepBookingDto keepBookingDto);

    void updateStatusByOutId(Integer outId);

    BillDetailVo getBillDetail(@Param("id") Integer id);

    EarlyRepaymentDetailVo getEarlyRepaymentDetail(DebtOneDto dto);

    Integer getIsUntreated(Integer outId, Integer orderId);

    BigDecimal getInterest(@Param("incomingId") Integer incomingId, @Param("outId") Integer outId);

    Integer selectisOverdueList(RepaymentSchedule repaymentSchedule);

    RepayDetailVo getRepayDetail(RepaymentScheduleDto dto);

    List<RepaymentSchedule> select(Date yesterday);

    List<RepaymentSchedule> selectInsurance(Date yesterday);

    long getDays(Integer outId);

    Integer checkRepay(Integer incomingId, Integer orderId);

    List<RepaymentScheduleList> getRepaymentScheduleList(Integer debtId);

    List<com.xd.core.openapi.vo.BillDetailVo> billDetail(Integer incomingId);

    Page<BillInfoVo> getAppList(Integer incomingId);
}
